package com.spring.component.test.xml;

import com.spring.component.xml.annotation.Level;
import com.spring.component.xml.annotation.Xml;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @ClassName: Order
 * @Description:
 * @author: liushihua
 * @date: 2018/12/6
 **/
@Level(value = 1, isList = true,
    xmls = {@Xml(attrName = "user", isAttr = true, isElement = true),
        @Xml(attrName = "date", isAttr = true, isElement = true, dateFormat = "yyyy-MM-dd"),
        @Xml(attrName = "price", isAttr = true, isElement = true), @Xml(attrName = "goodsList",
            xmlName = "Order", clazz = Goods.class, isElement = true, isList = true)})
public class Order {
  // @Xml(isAttr = true, isElement = true)
  private String user;
  // @Xml(isAttr = true, isElement = true)
  private Date date;
  // @Xml(isAttr = true, isElement = true)
  private String price;
  // @Xml(clazz = Goods.class, isElement = true, isList = true)
  private List<Goods> goodsList = new ArrayList<>();

  public void add(Goods goods) {
    this.goodsList.add(goods);
  }

  public String getUser() {
    return user;
  }

  public void setUser(String user) {
    this.user = user;
  }

  public Date getDate() {
    return date;
  }

  public void setDate(Date date) {
    this.date = date;
  }

  public String getPrice() {
    return price;
  }

  public void setPrice(String price) {
    this.price = price;
  }

  public List<Goods> getGoodsList() {
    return goodsList;
  }

  public void setGoodsList(List<Goods> goodsList) {
    this.goodsList = goodsList;
  }

  @Override
  public String toString() {
    return "Order{" + "user='" + user + '\'' + ", date='" + date + '\'' + ", price='" + price + '\''
        + ", goodsList=" + goodsList.toString() + '}';
  }
}
